package com.cqupt.interrgation.cquptinterrgation.controller;

import com.cqupt.interrgation.cquptinterrgation.entity.User;
import com.cqupt.interrgation.cquptinterrgation.mapper.Usermapper;
import com.cqupt.interrgation.cquptinterrgation.service.Userservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class Usercontroller {
    @Autowired
    private Usermapper usermapper;

    @Autowired
    private Userservice userservice;
    @GetMapping("/")
    public List<User> index(){
        return usermapper.findAll();
    }
    @GetMapping("name")
    public List<User> name(){
        return usermapper.findname();
    }
    @PostMapping("insert")
    public Integer save(@RequestBody User user){//requestboby将前台传入的json转为user类
        return userservice.save(user);
    }
}
